// dto 用于注释每个接口的文档详情

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty, IsNumber } from 'class-validator';
// 文章创建需要的入参
export class CreatePostDto {
  @ApiProperty({ description: '文章标题' })
  @IsNotEmpty({ message: '文章标题必填' })
  readonly title: string;

  @ApiPropertyOptional({ description: '内容' })
  readonly content: string;

  @ApiPropertyOptional({ description: '文章封面' })
  readonly coverUrl: string;

  @ApiPropertyOptional({ description: '文章状态(draft | publish)' })
  readonly status: string;

  @IsNumber()
  @ApiProperty({ description: '文章分类' })
  readonly category: number;

  @ApiPropertyOptional({ description: '是否推荐' })
  readonly isRecommend: boolean;

  @ApiPropertyOptional({ description: '文章标签' })
  readonly tag: string;
}

// 文章列表查询入参
export class searchPostDto {
  @ApiProperty({ description: '文章标题', required: false })
  readonly title: string;

  @ApiProperty({ description: '创建人', required: false })
  readonly username: string;

  @ApiProperty({ description: '文章分类', required: false })
  readonly category: number;

  @ApiProperty({ description: '单页数量' })
  @IsNotEmpty({ message: '页数量必填' })
  readonly pageSize: number;

  @ApiProperty({ description: '文章页码' })
  @IsNotEmpty({ message: '页码必填' })
  readonly page: number;
}  

export class PostInfoDto {
  public id: number;
  public title: string;
  public content: string;
  public contentHtml: string;
  public summary: string;
  public toc: string;
  public coverUrl: string;
  public isRecommend: boolean;
  public status: string;
  public userId: string;
  public author: string;
  public category: number;
  public tags: number[];
  public count: number;
  public likeCount: number;
}

export interface PostsRo {
  list: PostInfoDto[];
  total: number;
}
